extends CharacterBody2D

var speed = 300

@onready var sprite = $playeranimation

func _ready() -> void:
	sprite.flip_h = true



func _physics_process(delta):
	velocity.x = Input.get_axis("move_left", "move_right") * speed
	velocity.y = Input.get_axis("move_up", "move_down") * speed
	move_and_slide()
# 动画控制
	if GameUtiles.player_ani == "normal":
		if velocity.length() > 0:
			sprite.play("run")
		else:
			sprite.play("idle")
			
	
	
	# 翻转朝向
	if velocity.x != 0:
		sprite.flip_h = velocity.x > 0
		
func _process(delta: float) -> void:
	if not GameUtiles.move_allow:
		set_physics_process(false)
		set_process_input(false)
	else:
		set_physics_process(true)
		set_process_input(true)
	if GameUtiles.player_ani != "normal":
		if GameUtiles.player_ani == "fan_slow":
			sprite.play("fan_slow")
		elif GameUtiles.player_ani == "fan_fast":
			sprite.play("fan_fast")
		
		
		
